import request from "@/plugins/request";

var pre = "";
if (process.env.NODE_ENV !== "development") {
  pre = "/api/sa/eshop";
}

// 分页查询订单
export function orderPage(data) {
  return request({
    url: `${pre}/order/page`,
    method: "post",
    data,
  });
}

// 提交订单
export function submitOrder(data) {
  return request({
    url: `${pre}/order/submit`,
    method: "post",
    data,
  });
}

// 订单详情
export function getOrder(data) {
  return request({
    url: `${pre}/order/get?orderNo=${data}`,
    method: "get",
  });
}

// 取消订单
export function cancelOrder(data) {
  return request({
    url: `${pre}/order/cancel`,
    method: "post",
    data,
  });
}

// 删除订单
export function delOrder(data) {
  return request({
    url: `${pre}/order/del?orderNo=${data}`,
    method: "get",
  });
}

// 支付订单
export function payOrder(data) {
  return request({
    url: `${pre}/order/pay`,
    method: "post",
    data,
  });
}

//申请退款
export function refundOrder(data) {
  return request({
    url: `${pre}/order/refund/save`,
    method: "post",
    data,
  });
}

//取消退款
export function refundCancel(data) {
  return request({
    url: `${pre}/order/refund/cancel?orderNo=${data}`,
    method: "get",
  });
}

// 查询订单退款详细信息
export function takeOrderDetall(data) {
  return request({
    url: `${pre}/order/refund/get?orderNo=${data}`,
    method: "get",
  });
}

// 确认收货
export function takeOrder(data) {
  return request({
    url: `${pre}/order/receipt?orderNo=${data}`,
    method: "get",
  });
}

// 批量支付订单
export function batchOrder(data) {
  return request({
    url: `${pre}/order/batch-pay`,
    method: "post",
    data,
  });
}

// 确认收货
export function receiptOrder(data) {
  return request({
    url: `${pre}/order/receipt?orderNo=${data}`,
    method: "get",
  });
}

// 分页查询商家订单
export function searchPage(data) {
  return request({
    url: `${pre}/order-manage/page`,
    method: "post",
    data,
  });
}

// 取消商家订单
export function manageOrder(data) {
  return request({
    url: `${pre}/order-manage/cancel`,
    method: "post",
    data,
  });
}

// 商家订单发货
export function shipOrder(data) {
  return request({
    url: `${pre}/order-manage/deliver`,
    method: "post",
    data,
  });
}

// 商家订单详情
export function orderGet(data) {
  return request({
    url: `${pre}/order-manage/get?orderNo=${data}`,
    method: "get",
  });
}

export function queryFreight(data) {
  return request({
    url: `${pre}/shipping-calc/get`,
    method: "post",
    data,
  });
}

export function queryDelivery(data) {
  return request({
    url: `${pre}/order/delivery/get?orderNo=${data}`,
    method: "get",
  });
}
export function orderDelivery(data) {
  return request({
    url: `${pre}/order-manage/delivery/get?orderNo=${data}`,
    method: "get",
  });
}

// 查询订单退款详细信息
export function refundDetall(data) {
  return request({
    url: `${pre}/order-manage/refund/get?orderNo=${data}`,
    method: "get",
  });
}